package com.qf.sl.youshare.model;

import android.database.Cursor;

/**
 * Created by IDEA
 * User : sl
 * on 2015/2/26.
 * 19:47
 */
public class ProductCollect {
    /**
     * 数据库获取收藏的时候用到，用于对数据库删除的支持
     */
    private long id;

    private String pid;
    private String name;
    private float price;
    private String description;
    private String thumb;
    private String type;

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    /**
     * 获取表的记录的ID
     * @return
     */
    public long getId() {
        return id;
    }

    /**
     * 解析数据库记录
     * @param cursor
     */
    public void parseCursor(Cursor cursor) {
        if (cursor != null) {
            int index = cursor.getColumnIndex("pid");
            if (index != -1) {
                pid = cursor.getString(index);
            }
            index = cursor.getColumnIndex("price");
            if (index != -1) {
                price = cursor.getFloat(index);
            }
            index = cursor.getColumnIndex("name");
            if (index != -1) {
                name = cursor.getString(index);
            }
            index = cursor.getColumnIndex("description");
            if (index != -1) {
                description = cursor.getString(index);
            }
            index = cursor.getColumnIndex("thumb");
            if (index != -1) {
                thumb = cursor.getString(index);
            }
            index = cursor.getColumnIndex("type");
            if (index != -1) {
                type = cursor.getString(index);
            }
            index = cursor.getColumnIndex("_id");
            if (index != -1){
                id = cursor.getLong(index);
            }
        }
    }
}
